/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ccedeno
 */
@Entity
@Table(name = "interesado", catalog = "emilima_tradoc", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Interesado.findAll", query = "SELECT i FROM Interesado i"),
    @NamedQuery(name = "Interesado.findByIdInter", query = "SELECT i FROM Interesado i WHERE i.idInter = :idInter"),
    @NamedQuery(name = "Interesado.findByNombres", query = "SELECT i FROM Interesado i WHERE i.nombres = :nombres"),
    @NamedQuery(name = "Interesado.findByApePate", query = "SELECT i FROM Interesado i WHERE i.apePate = :apePate"),
    @NamedQuery(name = "Interesado.findByApeMat", query = "SELECT i FROM Interesado i WHERE i.apeMat = :apeMat")})
public class Interesado implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 3)
    @Column(name = "id_inter", nullable = false, length = 3)
    private String idInter;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "nombres", nullable = false, length = 45)
    private String nombres;
    @Size(max = 45)
    @Column(name = "ape_pate", length = 45)
    private String apePate;
    @Size(max = 45)
    @Column(name = "ape_mat", length = 45)
    private String apeMat;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "interesado", fetch = FetchType.LAZY)
    private List<InteresArea> interesAreaList;
    @JoinColumn(name = "fk_estado", referencedColumnName = "id_estado", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Estado estado;

    public Interesado() {
    }

    public Interesado(String idInter) {
        this.idInter = idInter;
    }

    public Interesado(String idInter, String nombres) {
        this.idInter = idInter;
        this.nombres = nombres;
    }

    public String getIdInter() {
        return idInter;
    }

    public void setIdInter(String idInter) {
        this.idInter = idInter;
    }

    public String getNombres() {
        return nombres;
    }

    public void setNombres(String nombres) {
        this.nombres = nombres;
    }

    public String getApePate() {
        return apePate;
    }

    public void setApePate(String apePate) {
        this.apePate = apePate;
    }

    public String getApeMat() {
        return apeMat;
    }

    public void setApeMat(String apeMat) {
        this.apeMat = apeMat;
    }

    @XmlTransient
    public List<InteresArea> getInteresAreaList() {
        return interesAreaList;
    }

    public void setInteresAreaList(List<InteresArea> interesAreaList) {
        this.interesAreaList = interesAreaList;
    }

    public Estado getEstado() {
        return estado;
    }

    public void setEstado(Estado estado) {
        this.estado = estado;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idInter != null ? idInter.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Interesado)) {
            return false;
        }
        Interesado other = (Interesado) object;
        if ((this.idInter == null && other.idInter != null) || (this.idInter != null && !this.idInter.equals(other.idInter))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
     //   return "Entidades.Interesado[ idInter=" + idInter + " ]";
           return idInter + " "+nombres;
    }
}
